import {LogLanguage} from "../dist/index.js"

// 测试括号排除功能
const testCases = [
  // 括号包围的类路径
  "2025-08-06 11:23:02,220 INFO  [TID:] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] points.PointsProcessor (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) - 【权益积分通道】 积分发放",
  
  // 多个括号类路径
  "2024-01-15 10:30:45 [INFO] (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) (com.cn.yft.ora.bank.sby.service.SBYBaseService:87) Database operation",
  
  // 混合格式
  "2024-01-15 10:30:45 [INFO] [TID:] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) Processing request"
]

console.log("=== 括号排除测试 ===")

testCases.forEach((testCase, index) => {
  console.log(`\n测试 ${index + 1}:`)
  console.log(`输入: ${testCase}`)
  
  // 检查括号包围的类路径识别
  const classPathRegex = /\(([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*:[0-9]+)\)/g
  let match
  let foundClassPaths = []
  
  while ((match = classPathRegex.exec(testCase)) !== null) {
    const fullMatch = match[0]  // 完整匹配，包括括号
    const content = match[1]    // 括号内的内容
    const from = match.index + 1  // 跳过左括号
    const to = from + content.length  // 只包含括号内的内容
    
    foundClassPaths.push({
      full: fullMatch,
      content: content,
      from: from,
      to: to,
      highlightedContent: testCase.slice(from, to)
    })
  }
  
  if (foundClassPaths.length > 0) {
    console.log("✓ 括号类路径识别成功:")
    foundClassPaths.forEach(classPath => {
      console.log(`  - 完整匹配: "${classPath.full}"`)
      console.log(`  - 括号内容: "${classPath.content}"`)
      console.log(`  - 高亮范围: ${classPath.from}-${classPath.to}`)
      console.log(`  - 高亮内容: "${classPath.highlightedContent}"`)
      console.log(`  - 括号排除: ${classPath.highlightedContent === classPath.content ? '✓' : '✗'}`)
    })
  } else {
    console.log("✗ 未找到括号包围的类路径")
  }
  
  // 验证括号是否被排除
  foundClassPaths.forEach(classPath => {
    const hasLeftBracket = classPath.highlightedContent.startsWith('(')
    const hasRightBracket = classPath.highlightedContent.endsWith(')')
    
    if (hasLeftBracket || hasRightBracket) {
      console.log(`✗ 错误: 高亮内容包含括号 "${classPath.highlightedContent}"`)
    } else {
      console.log(`✓ 正确: 括号已排除 "${classPath.highlightedContent}"`)
    }
  })
})
